package com.jic.market.mapper;

import com.jic.market.entity.PromotionRuleEntity;
import com.jic.market.orm.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.List;

@Repository
public interface PromotionRuleEntityMapper extends BaseMapper<PromotionRuleEntity>{
    Integer deleteByPromotionId(Long promotionId);

    @Select("select content_value from promotion_rule where promotion_id = #{promotionId} and delete_flag = 0 limit 1")
    Integer queryConditionValueByPromotionId(@Param("promotionId") Long promotionId);

    @Select("select content_value from promotion_rule where promotion_id = #{promotionId} and delete_flag = 0 limit 1")
    Integer queryContentValueByPromotionId(@Param("promotionId") Long promotionId);

    @Select("select * from promotion_rule where promotion_id = #{promotionId} and delete_flag = 0")
    List<PromotionRuleEntity> queryByPromotionId(@Param("promotionId") Long promotionId);

    @Select("select * from promotion_rule where promotion_id = #{promotionId} and delete_flag = 0 limit 1")
    PromotionRuleEntity queryPromotionRuleById(@Param("promotionId") Long promotionId);
}